package com.cloudkinto.service.shipprice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloudkinto.common.DicBusinessItemConstant;
import com.cloudkinto.common.constant.SysConstant;
import com.cloudkinto.common.exception.BizException;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.dao.*;
import com.cloudkinto.entity.*;
import com.cloudkinto.service.region.JpRegionService;
import com.cloudkinto.service.shipprice.DimensService;
import com.cloudkinto.service.shipprice.ShipPriceService;
import com.cloudkinto.service.shipprice.vo.ComputePriceReq;
import com.cloudkinto.service.shipprice.vo.ShipPriceRes;
import com.cloudkinto.service.shipprice.vo.WarehousingPriceReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * service实现类
 * </p>
 *
 * @author ding
 * @since 2020-06-09
 */
@Service
@Transactional(rollbackFor = Exception.class)//事务回滚
public class ShipPriceServiceImpl extends ServiceImpl<ShipPriceDao, ShipPriceDo> implements ShipPriceService {
    @Autowired
    private ShipPriceDao dao;
    @Autowired
    private DimensService mDimensService;
    @Autowired
    private JpRegionDao jpRegionDao;
    @Autowired
    private DimensDao dimensDao;
    @Autowired
    private CompanyDao companyDao;
    @Autowired
    private StorageDao storageDao;
    @Autowired
    private DicBusinessItemDao dicBusinessItemDao;
    @Autowired
    private ProductInfoDao mProductDao;
    @Autowired
    private JpRegionService mRegionService;
    @Autowired
    private FbaStorageDao fbaStorageDao;
    @Autowired
    private CompanyOperatePriceDao companyOperatePriceDao;
    @Autowired
    private ProductInfoDao productInfoDao;


    @Override
    public ShipPriceDo queryByRegionAndSize(Long stateId, double weight, double size, Double longest, Double minor, Double shortest, Long storageId, Long trackId, int version, Integer bundling) {
        return queryByRegionAndSize(stateId, weight, size, longest, minor, shortest, 0, 0, storageId, trackId, version, bundling);
    }


    public ShipPriceDo queryByRegionAndSize(String postCode, double weight, double size, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, Long trackId, int version, Integer bundling) {
        return queryByRegionAndSize(mRegionService.getStateIdByPostCode(postCode), weight, size, longest, minor, shortest, cod, shipmentType, storageId, trackId, version, bundling);
    }

    /**
     * 西农特殊处理
     *
     * @param stateId
     * @param weight
     * @param longest
     * @param minor
     * @param shortest
     * @param cod
     * @param shipmentType
     * @param storageId
     * @param trackId
     * @param version
     * @return
     */
    @Override
    public ShipPriceDo queryByRegionAndSize(Long stateId, double weight, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, Long trackId, int version, Integer bundling) {
        if (DicBusinessItemConstant.xinongExpress.equals(trackId)) {
            return this.queryByRegionAndSize(stateId, weight, new BigDecimal(longest * minor * shortest * 0.00028).setScale(1, BigDecimal.ROUND_UP).doubleValue(), longest, minor, shortest, cod, shipmentType, storageId, trackId, version, bundling);
        } else {
            return this.queryByRegionAndSize(stateId, weight, longest + minor + shortest, longest, minor, shortest, cod, shipmentType, storageId, trackId, version, bundling);
        }
    }

    public ShipPriceDo queryByRegionAndSize(Long stateId, double weight, double size, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, Long trackId, int version) {
        return  this.queryByRegionAndSize(stateId, weight, size, longest, minor, shortest, cod, shipmentType, storageId, trackId, version, null);
    }

        /**
         * 根据 三边和/重量/  算运费（确定快递公司）
         *
         * @param stateId   所属地区
         * @param weight    重量
         * @param size      三边和
         * @param storageId 仓库id
         * @param version   费用版本
         * @return
         */
    @Override
    public ShipPriceDo queryByRegionAndSize(Long stateId, double weight, double size, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, Long trackId, int version, Integer bundling) {
        DimensDo dimensDo = null;
        List<DimensDo> dimensIds = mDimensService.listBySizeAndWeight(size, weight, longest, minor, shortest, cod, shipmentType, storageId, trackId, bundling);
        if (dimensIds == null || dimensIds.size() < 1) {
            return new ShipPriceDo();
        }
        dimensDo = dimensIds.get(0);
        LambdaQueryWrapper<ShipPriceDo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ShipPriceDo::getStateId, stateId)
                .eq(ShipPriceDo::getDimensId, dimensDo.getId())
                .eq(ShipPriceDo::getActive, 1)
                .eq(ShipPriceDo::getVersion, version)
                .last("limit 1");
        LambdaQueryWrapper<ShipPriceDo> originalWrapper = new LambdaQueryWrapper<>();
        originalWrapper.eq(ShipPriceDo::getStateId, stateId)
                .eq(ShipPriceDo::getDimensId, dimensDo.getId())
                .eq(ShipPriceDo::getActive, 1)
                .eq(ShipPriceDo::getVersion, 1)
                .last("limit 1");
        ShipPriceDo shipPrice = baseMapper.selectOne(wrapper);

        ShipPriceDo originalShipPrice = baseMapper.selectOne(originalWrapper);
        if (shipPrice != null) {
            if (originalShipPrice == null) {
                shipPrice.setOriginalPrice(0);
            } else {
                shipPrice.setOriginalPrice(originalShipPrice.getPrice().intValue());
            }
            return shipPrice;
        } else {
            wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(ShipPriceDo::getStateId, stateId)
                    .eq(ShipPriceDo::getDimensId, dimensDo.getId())
                    .eq(ShipPriceDo::getActive, 1)
                    .eq(ShipPriceDo::getVersion, 2)
                    .last("limit 1");
            shipPrice = baseMapper.selectOne(wrapper);
            if (shipPrice != null) {
                if (originalShipPrice == null) {
                    shipPrice.setOriginalPrice(0);
                } else {
                    shipPrice.setOriginalPrice(originalShipPrice.getPrice().intValue());
                }
                return shipPrice;
            }
        }
        return null;
    }



    @Override
    public List<ShipPriceDo> queryByRegionAndSize(Long stateId, double weight, double size, Double longest, Double minor, Double shortest, Long storageId, int version, Integer bundling) {
        return this.queryByRegionAndSize(stateId, weight, size, longest, minor, shortest, 0, 0, storageId, version, bundling);
    }

    @Override
    public List<ShipPriceDo> queryByRegionAndSize(String postCode, double weight, double size, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, int version) {
        return this.queryByRegionAndSize(postCode, weight, size, longest, minor, shortest, cod, shipmentType, storageId, version, null);
    }


    @Override
    public List<ShipPriceDo> queryByRegionAndSize(String postCode, double weight, double size, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, int version, Integer bundling) {
        return queryByRegionAndSize(mRegionService.getStateIdByPostCode(postCode), weight, size, longest, minor, shortest, cod, shipmentType, storageId, version, bundling);
    }


    public List<ShipPriceDo> queryByRegionAndSize(Long stateId, double weight, double size, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, int version) {
        return this.queryByRegionAndSize(stateId, weight, size, longest, minor, shortest, cod, shipmentType, storageId, version, 1);
    }


        /**
         * 根据 三边和/重量/  选择最优运费
         *
         * @param stateId   所属地区
         * @param weight    重量
         * @param size      三边和
         * @param storageId 仓库id
         * @param version   费用版本
         * @return
         */
    @Override
    public List<ShipPriceDo> queryByRegionAndSize(Long stateId, double weight, double size, Double longest, Double minor, Double shortest, Integer cod, Integer shipmentType, Long storageId, int version, Integer bundling) {
        List<ShipPriceDo> shipPriceList = new ArrayList<>();
        List<DimensDo> dimensIds = mDimensService.listBySizeAndWeight(size, weight, longest, minor, shortest, cod, shipmentType, storageId, bundling);
        if (dimensIds.size() < 1) {
            return shipPriceList;
        }

        ShipPriceDo less = null;
        for (DimensDo dimensDo : dimensIds) {
            LambdaQueryWrapper<ShipPriceDo> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(ShipPriceDo::getStateId, stateId)
                    .eq(ShipPriceDo::getDimensId, dimensDo.getId())
                    .eq(ShipPriceDo::getActive, 1)
                    .eq(ShipPriceDo::getVersion, version)//特殊报价
                    .last("order by id desc limit 1");
            ShipPriceDo ship = baseMapper.selectOne(wrapper);
            if (ship == null) {
                wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(ShipPriceDo::getStateId, stateId)
                        .eq(ShipPriceDo::getDimensId, dimensDo.getId())
                        .eq(ShipPriceDo::getActive, 1)
                        .eq(ShipPriceDo::getVersion, 2) // 普通报价
                        .last("order by id desc limit 1");
                ship = baseMapper.selectOne(wrapper);
            }
            if (ship == null) {
                continue;
            }
            if (less == null || ship.getPrice() < less.getPrice()) {
                less = ship;
                //算成本
                wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(ShipPriceDo::getStateId, stateId)
                        .eq(ShipPriceDo::getDimensId, dimensDo.getId())
                        .eq(ShipPriceDo::getActive, 1)
                        .eq(ShipPriceDo::getVersion, 1) // 成本报价
                        .last("order by id desc limit 1");
                ShipPriceDo originalShip = baseMapper.selectOne(wrapper);
                if (originalShip != null) {
                    less.setOriginalPrice(originalShip.getOriginalPrice());
                }
            }
        }
        if (less != null) {
            shipPriceList.add(less);
        }
        return shipPriceList;
    }


    @Override
    public SingleResult computePrice(ComputePriceReq req, Long userId, Long companyId) {
        ShipPriceRes res = new ShipPriceRes();

        CompanyDo companyDo = companyDao.selectById(companyId);

        StorageDo storageDo = storageDao.selectById(req.getStorageId());

        JpRegionDo jpRegionDo = jpRegionDao.selectById(req.getRegionId());

        Double volume = req.getHeight() + req.getLength() + req.getWidth();
        Double weight = req.getWeight();

        double[] size = this.getSizeOrderDesc(req.getLength(), req.getWidth(), req.getHeight());

        List<ShipPriceDo> shipPriceDos = this.queryByRegionAndSize(jpRegionDo.getJpStateId(), weight, volume, size[0], size[1], size[2], 0, 0, storageDo.getId(), companyDo.getShipPriceVersion(), 1);

        if (!CollectionUtils.isEmpty(shipPriceDos)) {
            res.setPrice(shipPriceDos.get(0).getPrice());
            res.setStorage(storageDo.getStorageName());
            DimensDo dimensDo = dimensDao.selectById(shipPriceDos.get(0).getDimensId());
            DicBusinessItemDo businessItemDo = dicBusinessItemDao.selectById(dimensDo.getTrackId());
            res.setTrackName(businessItemDo.getDicItemValue());
        }


        return SingleResult.success(res);
    }

    @Override
    public SingleResult computeInit() {
        Map result = new HashMap();

        List<Map> storageList = new ArrayList<>();
        List<StorageDo> storageDoList = storageDao.selectList(null);
        if (!CollectionUtils.isEmpty(storageDoList)) {
            storageDoList.forEach(storageDo -> {
                Map map = new HashMap();
                map.put("id", storageDo.getId());
                map.put("value", storageDo.getStorageName());
                storageList.add(map);
            });
        }
        result.put("storageList", storageList);

        List<Map> companyList = new ArrayList<>();
        List<CompanyDo> companyDoList = companyDao.selectList(null);
        if (!CollectionUtils.isEmpty(companyDoList)) {
            companyDoList.forEach(companyDo -> {
                Map map = new HashMap();
                map.put("id", companyDo.getId());
                map.put("value", companyDo.getCompanyCode());
                companyList.add(map);
            });
        }
        result.put("companyList", companyList);

        List<Map> fbaStorageList = new ArrayList<>();
        List<FbaStorageDo> fbaStorageDoList = fbaStorageDao.selectList(null);
        if (!CollectionUtils.isEmpty(fbaStorageDoList)) {
            fbaStorageDoList.forEach(storageDo -> {
                Map map = new HashMap();
                map.put("id", storageDo.getId());
                map.put("value", storageDo.getFbaName());
                map.put("codeValue", storageDo.getFbaCode());
                fbaStorageList.add(map);
            });
        }
        result.put("fbaStorageList", fbaStorageList);

        List<Map> regionList = new ArrayList<>();
        List<JpRegionDo> regionDoList = jpRegionDao.selectList(null);
        if (!CollectionUtils.isEmpty(regionDoList)) {
            regionDoList.forEach(regionDo -> {
                Map map = new HashMap();
                map.put("id", regionDo.getId());
                map.put("value", regionDo.getName());
                regionList.add(map);
            });
        }
        result.put("regionList", regionList);
        return SingleResult.success(result);
    }


    /**
     * 计算多个不同sku
     *
     * @param productDoList
     * @return float[]{最长边.次长边,短边和，重量}
     */
    @Override
    public double[] getMulitSkuSize(List<OrderOutputProductDo> productDoList) {
        double[] finalSize = new double[4];
        if (productDoList == null || productDoList.size() == 0) {
            return finalSize;
        }
        for (OrderOutputProductDo productDo : productDoList) {
            finalSize = countSameSkuSize(finalSize, productDo.getProductId(), productDo.getCount());
        }

        return finalSize;
    }

    /**
     * 获取多个SKu的操作费
     *
     * @param productDoList
     * @param companyId
     * @return
     */
    @Override
    public int getMulitSkuOperationFeeNoPackage(List<OrderOutputProductDo> productDoList, String companyId) {
        //查询公司费用报价
        List<CompanyOperatePriceDo> priceDoList = companyOperatePriceDao.getList(companyId);
        if (priceDoList.size() == 0) {
            //取默认报价
            priceDoList = companyOperatePriceDao.getList("-1");
        }

        int fee = 0;
        if (productDoList != null && productDoList.size() > 0) {
            for (OrderOutputProductDo product : productDoList) {
                ProductInfoDo productInfoDo = mProductDao.selectById(product.getProductId());
                float totalSize = productInfoDo.getWidth() + productInfoDo.getHeight() + productInfoDo.getLength();
                price:
                for (CompanyOperatePriceDo priceDo : priceDoList) {
                    if (totalSize < priceDo.getSize()) { //60
                        fee = fee + priceDo.getPrice() * product.getCount();
                        break;
                    } else if (priceDo.getSize() == 0) {
                        fee = fee + priceDo.getPrice() * product.getCount();
                        break;
                    }
                }
            }
        }
        return fee;
    }

    /**
     * 获取多个SKu的操作费
     *
     * @param packageDetailDoList
     * @param productDoList
     * @param companyId
     * @return
     */
    @Override
    public int getMulitSkuOperationFee(List<OrderOutputPackageDetailDo> packageDetailDoList, List<OrderOutputProductDo> productDoList, String companyId) {
        //查询公司费用报价
        List<CompanyOperatePriceDo> priceDoList = companyOperatePriceDao.getList(companyId);
        if (priceDoList.size() == 0) {
            //取默认报价
            priceDoList = companyOperatePriceDao.getList("-1");
        }
        int fee = 0;
        if (packageDetailDoList == null || packageDetailDoList.size() < 1) {
            for (OrderOutputProductDo productDo : productDoList) {
                ProductInfoDo productInfoDo = mProductDao.selectById(productDo.getProductId());
                float totalSize = productInfoDo.getWidth() + productInfoDo.getHeight() + productInfoDo.getLength();
                for (CompanyOperatePriceDo priceDo : priceDoList) {
                    if (totalSize < priceDo.getSize()) { //60
                        fee = fee + priceDo.getPrice();
                        fee = fee + (productDo.getCount() - 1) * priceDo.getBalePrice();
                        break;
                    } else if (priceDo.getSize() == 0) {
                        fee = fee + priceDo.getPrice();
                        fee = fee + (productDo.getCount() - 1) * priceDo.getBalePrice();
                        break;
                    }
                }
            }
        } else {
            for (OrderOutputPackageDetailDo packageDetailDo : packageDetailDoList) {
                String[] inSkuIds = packageDetailDo.getInSkuId().split(",");
                if (inSkuIds == null || inSkuIds.length < 1) continue;
                Map<String, Integer> stringIntegerMap = Arrays.stream(inSkuIds).collect(Collectors.toMap(s -> s, s -> 1, Integer::sum));
                for (String skuId : stringIntegerMap.keySet()) {
                    ProductInfoDo productInfoDo = mProductDao.selectById(skuId);
                    if (productInfoDo == null) continue;
                    float totalSize = productInfoDo.getWidth() + productInfoDo.getHeight() + productInfoDo.getLength();
                    for (CompanyOperatePriceDo priceDo : priceDoList) {
                        if (totalSize < priceDo.getSize()) { //60
                            fee = fee + priceDo.getPrice();
                            fee = fee + (stringIntegerMap.get(skuId) - 1) * priceDo.getBalePrice();
                            break;
                        } else if (priceDo.getSize() == 0) {
                            fee = fee + priceDo.getPrice();
                            fee = fee + (stringIntegerMap.get(skuId) - 1) * priceDo.getBalePrice();
                            break;
                        }
                    }
                }
            }
        }
        return fee;
    }

    /**
     * 获取多个相同SKu的操作费
     *
     * @param productId
     * @param count
     * @param companyId
     * @return
     */
    @Override
    public int getSameSkuOperationFee(Long productId, int count, String companyId) {
        int fee = 0;
        ProductInfoDo productInfoDo = mProductDao.selectById(productId);
        float totalSize = productInfoDo.getWidth() + productInfoDo.getHeight() + productInfoDo.getLength();
        if (companyId.equals("255")) {
            fee = fee + 100 + (count - 1) * 50;
        } else if (totalSize < 60 || ((companyId.equals("221") || companyId.equals("316")) && totalSize < 100)) {
            fee = fee + 100 + (count - 1) * 50;
        } else {
            fee = fee + 200 + (count - 1) * 100;
        }
        return fee;
    }

    /**
     * 计算单个相同sku
     *
     * @param productId
     * @param count
     * @return
     */
    @Override
    public double[] countSameSkuSize(Long productId, int count) {
        double[] finalSize = new double[4];
        QueryWrapper wrapper = new QueryWrapper();
        ProductInfoDo productBean = mProductDao.selectById(productId);
        double[] size = getSizeOrderDesc(productBean.getWidth()
                , productBean.getHeight(), productBean.getLength());
        finalSize[0] = size[0];
        finalSize[1] = size[1];
        finalSize[2] = size[2];
        //最短边相加
        if (finalSize[0] + finalSize[1] + finalSize[2] < 55 && finalSize[2] <= 3 && finalSize[0] <= 34) {
            finalSize[1] = finalSize[1] + size[1] * (count - 1);
        } else {
            finalSize[2] = finalSize[2] + size[2] * (count - 1);
        }
        finalSize[3] = finalSize[3] + productBean.getWeight() * count;
        return finalSize;
    }

    /**
     * 计算单个/多个相同sku
     *
     * @param finalSize
     * @param productId
     * @param count
     * @return
     */
    @Override
    public double[] countSameSkuSize(double[] finalSize, Long productId, int count) {
        finalSize = countSameSkuSizeNew(finalSize, productId, count);
        double[] size = this.getSizeOrderDesc(finalSize[0], finalSize[1], finalSize[2]);
        finalSize[0] = size[0];
        finalSize[1] = size[1];
        finalSize[2] = size[2];
        return finalSize;
    }

    /**
     * 计算单个/多个相同sku
     *
     * @param productId
     * @param count
     * @return
     */
    @Override
    public double[] countSameSkuSizeNew(double[] inputSize, Long productId, int count) {
        ProductInfoDo productBean = mProductDao.selectById(productId);
        if (productBean == null) return new double[4];
//        double[] size = getSizeOrderDesc(productBean.getWidth()
//                , productBean.getHeight(), productBean.getLength());
        return countSameSkuSizeNew(inputSize, productBean.getWidth(), productBean.getHeight(), productBean.getLength(), productBean.getWeight(), count);
    }

    /**
     * 计算单个/多个相同sku
     *
     * @param
     * @param count
     * @return
     */
    @Override
    public double[] countSameSkuSizeNew(double[] inputSize, double size0, double size1, double size2, double weight, int count) {
        double[] outSizeSize = new double[4];
        double[] size = getSizeOrderDesc(size0, size1, size2);

        if (Math.max(size[2], inputSize[2]) < 2.5 && inputSize[1] + size[1] * count < 22.8 && Math.max(size[0], inputSize[0]) < 31.2 && (size[0] + size[1] + size[2]) < 60 && size[2] < 1 &&
                (Math.max(inputSize[0], size[0])) + inputSize[1] + size[1] * count + (Math.max(inputSize[2], size[2])) < 60) {
            //黑猫小包
            //最长边小于 31.2 次长边小于22.8 最短边小于2.5  三遍和小于 60 重量小于1kg 20.5 14.5
            outSizeSize[0] = inputSize[0];
            outSizeSize[2] = inputSize[2];
            outSizeSize[1] = inputSize[1] + size[1] * count;
        }
        //次短边相加
        //如果最短边小于3，次短边相加小于34，次短边相加总边长小于55 ，则次短边相加   邮政小包
        else if (((Math.max(inputSize[0], size[0])) + inputSize[1] + size[1] * count + (Math.max(inputSize[2], size[2])) < 55
                && inputSize[2] <= 3 && inputSize[0] <= 34 && inputSize[1] + size[1] * count <= 34) &&
                size[0] + size[1] + size[2] < 55 && size[2] <= 3 && size[0] <= 34) {
            outSizeSize[0] = inputSize[0];
            outSizeSize[2] = inputSize[2];
            outSizeSize[1] = inputSize[1] + size[1] * count;
        } else {
            outSizeSize[0] = inputSize[0];
            outSizeSize[1] = inputSize[1];
            outSizeSize[2] = inputSize[2] + size[2] * count;
        }
        for (int i = 0; i < size.length; i++) {
            if (outSizeSize[i] < size[i]) {
                outSizeSize[i] = size[i];
            }
        }
        outSizeSize[3] = inputSize[3] + weight * count;
        return outSizeSize;
    }

    /**
     * 获取三边有大到小排序
     * * @param width
     *
     * @param height
     * @param length
     * @return
     */
    @Override
    public double[] getSizeOrderDesc(double width, double height, double length) {
        double[] floats = new double[]{width, height, length};
        for (int i = 0; i < floats.length; i++) {
            for (int j = 0; j < floats.length - i - 1; j++) {   // 这里说明为什么需要-1
                if (floats[j] < floats[j + 1]) {
                    double temp = floats[j];
                    floats[j] = floats[j + 1];
                    floats[j + 1] = temp;
                }
            }
        }
        return floats;
    }

    @Override
    public SingleResult warehousingPrice(WarehousingPriceReq req, Long userId, Long companyId) {
        StorageDo storageDo = storageDao.selectById(req.getStorageId());
        if (storageDo == null) {
            throw new BizException(SysConstant.Storage_NotExist);
        }
        double price;
        //梯度计算仓储费
        if (req.getDays() <= 60) {
            price = storageDo.getDayPrice() * req.getDays();
        } else if (req.getDays() > 60 && req.getDays() <= 120) {
            price = storageDo.getDayPrice() * 60 + (req.getDays() - 60) * storageDo.getDayPrice1();
        } else {
            price = storageDo.getDayPrice() * 60 + (req.getDays() - 60) * storageDo.getDayPrice1() + (req.getDays() - 120) * storageDo.getDayPrice2();
        }
        double volume = req.getLength() * req.getWidth() * req.getHeight() / 1000000;
        double result = volume * price;
        return SingleResult.success(result);
    }

}
